package com.aishua.aishuawallet.fregment;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.aishua.aishuawallet.R;
import com.aishua.aishuawallet.adapter.AccountAdapter;
import com.aishua.aishuawallet.adapter.ManagerAdapter;
import com.aishua.aishuawallet.adapter.MyItemDecoration;
import com.aishua.aishuawallet.adapter.RecycleViewDivider;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by aishua on 2018/7/31.
 */

public class TwoFregment extends BaseFragment {

    private Context mContext;
    private RecyclerView rl_manager;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        super.onCreateView(inflater, container, savedInstanceState);

        mContext = getContext();
        View view = View.inflate(mContext, R.layout.fregment_two,null);

        initVeiw(view);
        return view;
    }

    private void initVeiw(View view) {

        rl_manager = view.findViewById(R.id.rl_manager);
        RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getContext(), 3);

        rl_manager.setLayoutManager(layoutManager);
//        rl_account.setItemAnimator(new DefaultItemAnimator());
//        rl_manager.addItemDecoration(new RecycleViewDivider(getContext(), LinearLayoutManager.VERTICAL, 2, Color.GRAY));
        rl_manager.addItemDecoration(new MyItemDecoration(mContext));

        List<Drawable> drawbalelist = new ArrayList();

        drawbalelist.add(getResources().getDrawable(R.drawable.pwmanager));
        drawbalelist.add(getResources().getDrawable(R.drawable.emailmanager));
        drawbalelist.add(getResources().getDrawable(R.drawable.lossmanager));
        drawbalelist.add(getResources().getDrawable(R.drawable.backup));
        drawbalelist.add(getResources().getDrawable(R.drawable.recovery));
        List<String> textlist = new ArrayList();
        textlist.add(getResources().getString(R.string.pwmgt));
        textlist.add(getResources().getString(R.string.mailboxbinding));
        textlist.add(getResources().getString(R.string.reportloss));
        textlist.add(getResources().getString(R.string.chainbackup));
        textlist.add(getResources().getString(R.string.chainrecovery));

       ManagerAdapter managerAdapter = new ManagerAdapter(mContext, (ArrayList) drawbalelist,textlist);
        rl_manager.setAdapter(managerAdapter);
        managerAdapter.setonRecycleViewClickListener(new ManagerAdapter.onRecycleViewClickListener() {
            @Override
            public void onRecycleViewClick(int position) {

                Toast.makeText(mContext,getResources().getString(R.string.developing),Toast.LENGTH_SHORT).show();
            }
        });
    }

}
